/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ${USER}
 * Date: ${YEAR}-${MONTH}-${DAY}
 * Time: ${TIME}
 */
public class Main {
    public static void main(String[] args) {
        for (int i = 1; i < 99999; i++) {
            int count = 0;
            int tamp = i;
            int re = 0;
            while(tamp != 0){
                tamp /= 10;
                count++;
            }
            tamp = i;
            while(tamp != 0){
                re += Math.pow(tamp % 10,count);
                tamp /= 10;
            }
            if(re == i){
                System.out.println(i);
            }
        }

    }
}